package com.ghsc.ghxc.jsb.ui.home.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.cn.appcore.ext.load
import com.cn.appcore.ext.loge
import com.cn.appcore.ext.transformRoundCorner
import com.cn.appcore.utils.GlideUtil
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.ui.home.bean.BannerBean
import com.ghsc.ghxc.jsb.ui.home.bean.HomeBannerLunBoResult
import com.ghsc.ghxc.jsb.ui.integral.bean.Lunbo
import com.youth.banner.adapter.BannerAdapter
import com.youth.banner.util.BannerUtils


class HomeBannerAdapter(data: List<BannerBean?>?) : BannerAdapter<BannerBean?,VipBannerImageViewHolder>(data) {


    override fun onCreateHolder(parent: ViewGroup, viewType: Int): VipBannerImageViewHolder {
        return VipBannerImageViewHolder(BannerUtils.getView(parent, R.layout.layout_banner_item))
    }

    override fun onBindView(holder: VipBannerImageViewHolder, data: BannerBean?, position: Int, size: Int) {
        if (data != null) {
            holder.ivBanner.load(data.images, builder = {
                transform(transformRoundCorner(20))
            })
        }
    }
}

class VipBannerImageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
    var ivBanner: ImageView = view.findViewById(R.id.ivBanner)

}

class CommodityDetailBannerAdapter(data: List<String>) : BannerAdapter<String?,CommodityDetailImageViewHolder>(data) {


    override fun onCreateHolder(parent: ViewGroup, viewType: Int): CommodityDetailImageViewHolder {
        return CommodityDetailImageViewHolder(BannerUtils.getView(parent, R.layout.layout_banner_item))
    }

    override fun onBindView(holder: CommodityDetailImageViewHolder, data: String?, position: Int, size: Int) {
        if (data != null) {
//            holder.ivBanner.scaleType = ImageView.ScaleType.FIT_XY
            GlideUtil.ImageLoad(holder.ivBanner.context,data,holder.ivBanner)
        }
    }
}

class CommodityDetailImageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
    var ivBanner: ImageView = view.findViewById(R.id.ivBanner)

}


class HomeIntegralBannerAdapter(data: List<Lunbo?>?) : BannerAdapter<Lunbo?,VipBannerImageViewHolder>(data) {


    override fun onCreateHolder(parent: ViewGroup, viewType: Int): VipBannerImageViewHolder {
        return VipBannerImageViewHolder(BannerUtils.getView(parent, R.layout.layout_banner_item))
    }

    override fun onBindView(holder: VipBannerImageViewHolder, data: Lunbo?, position: Int, size: Int) {
        if (data != null) {
            holder.ivBanner.load(data.image, builder = {
                transform(transformRoundCorner(20))
            })
        }
    }
}